package org.mj.im.common.enums;

import java.util.Arrays;
import java.util.List;

public enum IMTerminalType {
    WEB(0,"web"),
    APP(1,"app");

    ;

    IMTerminalType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private Integer code;
    private String desc;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
    public static List<Integer> terminalTypeList() {
        return Arrays.stream(IMTerminalType.values()).map(IMTerminalType::getCode).toList();
    }

    public static IMTerminalType fromCode(Integer code) {
        IMTerminalType[] values = IMTerminalType.values();
        for (IMTerminalType value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
